package com.wuxiaoqin.server.controller;



import com.wuxiaoqin.server.service.IUsersService;
import com.wuxiaoqin.server.service.impl.UsersServiceImpl;
import com.wuxiaoqin.uitls.respObj.RespBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2021-10-22
 */
@RestController
@ApiOperation("用户操作")
@RequestMapping("/users")
public class UsersController {
    @Autowired
    private IUsersService usersService;
    @ApiOperation(value = "更改用户密码")
    @PostMapping("/passmod")
    public RespBean passmod(@RequestParam("orgPass") String orgPass,
                            @RequestParam("newPass") String newPass) throws InvalidKeySpecException, NoSuchAlgorithmException {
        return usersService.passmod(orgPass,newPass);
    }

    @ApiOperation(value = "修改用户信息")
    @PostMapping("/infoModify")
    public RespBean infoModify( @RequestParam("name") String name,
                                @RequestParam("sex") String sex,
                                @RequestParam("email") String email,
                                @RequestParam("signature") String signature)  {

        RespBean respBean=usersService.userInfoModify(name,sex,email,signature);
        return RespBean.success("修改成功");
    }

}
